from login.models import Batch
from paper.models import Question
from .patch import PatchPaper
class BatchDetail:

    def __init__(self,paper_obj):
        self.paper_obj = paper_obj

    def BatchConvert(self):
        paper_info = eval(self.paper_obj.paper_info)
        paper_dict = PatchPaper(paper_info).ConvertInfo()
        batch_obj = Batch.objects.get(paper_name = self.paper_obj)
        batch_info = eval(batch_obj.batch_detail)
        new_info_dict = {}
        for key,value in batch_info.copy().items():
            if key != 'total_score':
                qu_obj = Question.objects.get(pk = key)
                new_info_dict[qu_obj] = value[:]
        for q_type,info_list in paper_dict.copy().items():
            if q_type != 'total_score':
                for que_list in info_list[2][:]:
                    que_list.append(new_info_dict[que_list[0]][0])
        paper_dict['total_score'] = batch_info['total_score'][0]
        return paper_dict
    











        
